package com.nfIt.servlet;

import com.nfIt.Dbutils.GsonUtil;
import com.nfIt.dao.StaffsDao;
import com.nfIt.dao.impl.StaffsDaoImpl;
import com.nfIt.pojo.staffs;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * ClossName:SelectAllStaff
 * Pakage:com.nfIt.servlet
 * Description
 *
 * @Author L
 * @Create 2024/3/12 10:59
 * @Version 2023.1.3
 */
@WebServlet("/SelectAllStaff")
public class SelectAllStaff extends HttpServlet {
        @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        resp.setCharacterEncoding("utf-8");
        resp.setContentType("application/json;charset=utf-8");

        StaffsDao staffsDao = new StaffsDaoImpl();
        List<staffs>  list= staffsDao.staffsAll();

        String json = GsonUtil.toJson(list);

        PrintWriter out = resp.getWriter();
        out.print(json);
        out.flush();
        out.close();


    }
}
